<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>下拉菜单</title>

    <style>
        * {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        
        .nav {
            margin: 100px 500px;
            text-align: center;
        }
        
        .nav ul {
            display: none;
        }
        
        a {
            text-decoration: none;
            display: block;
            width: 100%;
            height: 100%;
            line-height: 41px;
            color: #333;
        }
        
        .nav ul li a:hover {
            background-color: #FFF5DA;
        }
        
        .nav>li {
            float: left;
            text-align: center;
            width: 80px;
            height: 50px;
            list-style: none;
            display: inline-block;
        }
        
        .nav>li>ul>li {
            border: 1px solid yellowgreen;
        }
    </style>

</head>

<body>

    <ul class="nav">
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#">微博</a>
            <ul>
                <li>
                    <a href="">私信</a>
                </li>
                <li>
                    <a href="">评论</a>
                </li>
                <li>
                    <a href="">@我</a>
                </li>
            </ul>
        </li>
    </ul>
</body>

<script>
    var ul = document.querySelector('.nav');

    console.log(ul.children);



    var lis = ul.children;
    for (var i = 0; i < lis.length; i++) {

        lis[i].onmouseover = function() {
            this.children[1].style.display = 'block';
            console.log(this.children);
        }

        lis[i].onmouseout = function() {
            this.children[1].style.display = 'none';

        }
    }
</script>

</html>